<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我喜欢你</title>
</head>
<body>
    <div id="app">

    </div>
    <script src="./lib/react.development.js"></script>
    <script src="./lib/react-dom.development.js"></script>
    <script src="./lib/babel.min.js"></script>
    <script src="./lib/propTypes.js"></script>
    <script type="text/babel">
        // 需求: 定义一个人员信息 信息从外部传入
        // 1. 姓名必须指定 2. 性别没有指定的话 默认为男  3. 年龄没有指定的话，默认为18
        class Like extends React.Component{
            constructor(props) {
                super(props)
                this.state = {
                    flag: true
                }
            }
            handleClick = () => {
                const  { flag } = this.state
                this.setState({
                    flag: !flag
                })
            }
            render() {
                const  { flag } = this.state
                const msg = flag ? '我喜欢你' : '你喜欢我'
                const {name,sex,age} = this.props
                return (
                    <div>
                    <h1>{name}</h1>
                    <h1>{sex}</h1>
                    <h1>{age}</h1>    
                    </div>
                )
            }
        }
        Like.propTypes = { 
            name: PropTypes.string.isRequired 
        }
        
        Like.defaultProps = {
            sex: '男',
            age: 18,
        }

        const info = {
            name: '张三'
        }


        ReactDOM.render(<Like {...info} />,document.getElementById('app'))
    </script>
</body>
</html>